import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;

public class Server {
	
	static private ServerSocket serverSocket = null;
	static private Socket clientSocket;

	public static void main(String[] args) {
		//arguents: port, chipsForPlayers playerNumber, bigBlindBet, smallBlindBet
		int port=0;
		int chipsForPlayers = 0;
		int playerNumber = 0;
		int bigBlindBet = 0;
		int smallBlindBet = 0;
		if (args.length != 5)
		{
			System.out.println("need 5 arguments!: port, chips for players, player number, big blind, small blind");
			System.exit(0);
		}
		try
		{
			port = Integer.parseInt(args[0]);
			chipsForPlayers = Integer.parseInt(args[1]);
			playerNumber = Integer.parseInt(args[2]);
			bigBlindBet = Integer.parseInt(args[3]);
			smallBlindBet = Integer.parseInt(args[4]);
		}
		catch(NumberFormatException e)
		{
			System.out.println("All arguments have to be numbers!");
			System.exit(1);
		}
		if (chipsForPlayers < 100 || chipsForPlayers > 1000000)
		{
			System.out.println("Choose Chips form [100..1000000]");
			System.exit(0);
		}
		if (playerNumber < 2 || playerNumber > 6)
		{
			System.out.println("Choose Players Number form [2..6]");
			System.exit(0);
		}
		if ((chipsForPlayers/bigBlindBet)<2)
		{
			System.out.println("Big Blind bet too big!");
			System.exit(0);
		}
		if (smallBlindBet >= bigBlindBet)
		{
			System.out.println("Small blind bet cant be bigger than big blind bet");
			System.exit(0);
		}
		
		GlobalVariables.players_number = playerNumber;
		GlobalVariables.players_connected = 0;
		GlobalVariables.server_status = 0;
		
		MainServerThread serv = new MainServerThread(port, playerNumber, smallBlindBet, bigBlindBet, chipsForPlayers);
		serv.start();
	}


}
